<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>2048-俺要当行长</title>

  <link href="style/main.css" rel="stylesheet" type="text/css">
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="apple-touch-icon" href="meta/apple-touch-icon.png">
  <link rel="apple-touch-startup-image" href="meta/apple-touch-startup-image-640x1096.png" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)"> <!-- iPhone 5+ -->
  <link rel="apple-touch-startup-image" href="meta/apple-touch-startup-image-640x920.png"  media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)"> <!-- iPhone, retina -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">

  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
</head>
<body>
  <div class="container">
    <div class="heading">
  <img src="logo.png" class="logo" alt="游戏logo">
      <h1 class="game-title">2048-俺要当行长</h1>
        <a class="restart-button top-new-game">新游戏</a>
      <div class="scores-container">
        <div class="score-row">
          <div class="best-level-container">0</div>
          <div class="best-container">0</div>
        </div>
        <div class="score-row">
          <div class="level-container">当前最高等级0</div>
          <div class="score-container">0</div>
        </div>
      </div>
    </div>

    <div class="above-game">
    </div>

    <div class="game-container">
      <div class="game-message">
        <p></p>
        <div class="lower">
	        <a class="keep-playing-button">继续游戏</a>
          <a class="retry-button">再试一次</a>
        </div>
      </div>

      <div class="grid-container">
        <div class="grid-row">
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
        </div>
        <div class="grid-row">
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
        </div>
        <div class="grid-row">
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
        </div>
        <div class="grid-row">
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
          <div class="grid-cell"></div>
        </div>
      </div>

      <div class="tile-container">

      </div>
    </div>


  </div>

  <script src="js/bind_polyfill.js"></script>
  <script src="js/classlist_polyfill.js"></script>
  <script src="js/animframe_polyfill.js"></script>
  <script src="js/keyboard_input_manager.js"></script>
  <script src="js/html_actuator.js"></script>
  <script src="js/grid.js"></script>
  <script src="js/tile.js"></script>
  <script src="js/local_storage_manager.js"></script>
  <script src="js/game_manager.js"></script>
  <script src="js/application.js"></script>
<script>
// 动态缩放游戏容器以适应不同设备分辨率
function setupDynamicScaling() {
  const container = document.querySelector('.game-container');
  if (!container) return;

    // 从CSS获取基础设计尺寸
    const containerStyle = window.getComputedStyle(container);
    const baseWidth = parseInt(containerStyle.width);
    const baseHeight = parseInt(containerStyle.height);

  // 获取设备可用尺寸
  const getAvailableSize = () => {
    const windowWidth = window.innerWidth;
    const windowHeight = window.innerHeight;
    const availableWidth = Math.min(windowWidth * 0.9, baseWidth);
    const availableHeight = Math.min(windowHeight * 0.7, baseHeight);
    return { width: availableWidth, height: availableHeight };
  };

  // 计算并应用缩放
  const applyScaling = () => {
    const { width, height } = getAvailableSize();
    const scale = Math.min(width / baseWidth, height / baseHeight);
    container.style.transform = `scale(${scale})`;
    container.style.transformOrigin = 'top center';
    container.style.margin = '0 auto';
    container.style.display = 'block';
  };

  // 初始应用和窗口大小变化时重新应用
  applyScaling();
  window.addEventListener('resize', applyScaling);
}

// 在DOM加载完成后执行
document.addEventListener('DOMContentLoaded', setupDynamicScaling);
</script>

</body>
</html>